<template>
	<view>
		{{title}}
	</view>
	<view>
		<button @click="saveToken">添加缓存</button>
	</view>
	<view>
		<button @click="delToken">删除缓存</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:"我的test测试"
			}
		},
		onLoad(options) {
			//判断有缓存,读缓存
			let token=uni.getStorageSync("token")
			if(token){
				console.log("有缓存token:",token)
				this.title="有缓存,token:"+token
			}else{
				console.log("没有缓存")
			}
			/* name age 相当于options中有2个属性 */
			/* console.log("name:",options.name)
			console.log("age:",options.age)
			console.log(options) */
			//this.title=options.name
			/* 发送请求 访问https://www.baidu.com */
			/* uni.request({
				url: "https://www.baidu.com?title="+this.title,
				method: "GET",
				success: (res)=>{
					/* 处理正确请求方法逻辑 
					let body=res.data
					console.log("baidu返回数据:",body)
				},
				fail: (error)=> {
					console.log("访问失败,原因:",error)
				}
			}), */
			
		},
		methods: {
			saveToken(){
				uni.setStorageSync("token","王翠花")
			},
			delToken(){
				uni.removeStorageSync("token")
			}
		}
	}
</script>

<style>

</style>
